var db = require('./db').get();
db.connection.on('open', function() {
    db.directory.findOne({
        name: "d06c59"
    }).then(function(doc) {
        console.log('read1', doc.toJSON().content);
        doc.content = [];
        doc.markModified('content');
        setTimeout(function() {

            doc.save().then(function(doc) {
                console.log('write1', doc.toJSON().content);
            });
        }, 3000);
            
    })


    db.directory.findOne({
        name: "d06c59"
    }).then(function(doc) {
        // 若这里不为空则意味着多线程不安全
        console.log('read2', doc.toJSON().content);
        doc.markModified('content');
        setTimeout(function() {
            
            doc.save().then(function(doc) {
                console.log('write2', doc.toJSON().content);
            });
        }, 6000);
    })

    setTimeout(function() {
        db.directory.findOne({
            name: "d06c59"
        }).then(function(doc) {
            console.log('9s', doc.toJSON().content);
            // 若这里不为['5bde63fc90f2881fc80eca2d', '5bde63fc90f2881fc80eca2f']则意味着多线程不安全
        })
    }, 9000)
})
    